package com.zoffy.ybuhelper.fragment;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import com.zoffy.ybuhelper.R;
import org.jetbrains.annotations.NotNull;

public class LoginFragment extends AbstractLoginFragment {
    @Override
    protected void layoutInit() {
        layout3.setVisibility(View.GONE);
    }

    @Override
    protected void listenerInit() {

        EditText passwordEdit=editText2;
        EditText accountEdit=editText1;


        saveAcountButton.setOnClickListener(v -> {
            String account= accountEdit.getText().toString();
            String password=passwordEdit.getText().toString();
            SharedPreferences preferences=  getActivity().getSharedPreferences("user_data", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor= preferences.edit();
            editor.putString("password",password);
            editor.putString("account",account);
            editor.commit();
            HomeFragment parent=(HomeFragment) getParentFragment();
            parent.update();
            getParentFragmentManager().beginTransaction().remove(this).commit();
        });
    }

}
